/**
 * Copyright 2016 Qiyi Inc. All rights reserved.
 *
 * @file:   StatisticOcr.Dao.js
 * @path:   js-src/StatisticOcr/
 * @desc:   负责本模块的远程调用的静态对象
 * @author: zhang@qiyi.com
 * @date:   2015-01-07
 */
qui(
	function(require, exports, module){

        StatisticOcr.Dao = $.extend({}, Ancestor.Dao, {

            getExportData: function (data, callback) {
                var options = {
                    url: "/api/statisticOcr/list",
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function (data) {
                        callback.call(this, data);
                    },
                    error: function (data) {
                        callback.call(this, data);
                    }
                };
                Ancestor.Dao.ajax(options, '/statisticOcr/list');
            },

            getExportDataAll: function (params, handler) {
                var daoSelf = this;
                params.pageNo = 1;
                handler.lockHandler();
                var queryComponent = {
                    params: params,
                    dataArr: [],
                    phase:0,
                    hasFlushNum:0,
                    query: function () {
                        var self = this;
                        daoSelf.getExportData(params, function (data) {
                            if (data == null) {
                                EpgWeb.Plugin.showTips({content: "请求失败", type: "error"  })
                                handler.phaseHandler(self.dataArr);
                                handler.unlockHandler();
                            } else {
                                self.dataArr = self.dataArr.concat(data.data.result);
                                self.phase++;
                                handler.phaseHandler(self.dataArr,"phase"+self.phase);
                                console.log("self.phase:"+self.phase);
                                self.hasFlushNum += self.dataArr.length;
                                self.dataArr = [];
                                if (self.hasFlushNum < data.data.totalCount) {
                                    self.params["pageNo"] = params.pageNo + 1;
                                    console.log("params.pageNo:"+self.params["pageNo"]);
                                    self.query();
                                }else{
                                    handler.unlockHandler();
                                }
                            }
                        })
                    }
                };
                queryComponent.query();
            },

            //获取频道名称
            getCategoryName: function(data, callback) {
                var options = {
                    url: '/api/redirect',
                    dataType: 'json',
                    data: data,
                    method: 'post',
                    success: function(data) {
                        callback.call(this, data);
                    },
                    error: function(data) {
                        callback.call(this, data);
                    }
                };
                Ancestor.Dao.ajax(options,'/redirect');
            }
        });
	}
);